import Vue from 'vue'
import VueRouter from 'vue-router'


// 解决报错
// const originalPush = VueRouter.prototype.push
// const originalReplace = VueRouter.prototype.replace
//     // push
// VueRouter.prototype.push = function push(location, onResolve, onReject) {
//         console.log(onReject + onResolve)
//             // if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
//         return originalPush.call(this, location).catch(err => {
//             console.log(err)
//             originalPush.call(this, location, onResolve, onReject)
//         });
//     }
//     // replace
// VueRouter.prototype.replace = function push(location, onResolve, onReject) {
//     console.log(onReject + onResolve)
//         // if (onResolve || onReject) return originalReplace.call(this, location, onResolve, onReject)
//     return originalReplace.call(this, location).catch(err => {
//         console.log(err)
//         originalPush.call(this, location, onResolve, onReject)
//     })
// }


Vue.use(VueRouter)
const routes = [{
        path: '/',
        redirect: '/login'
    },

    {
        path: '/comment',
        name: 'comment',
        component: () =>
            import ('../views/comment/Comment'),
    },
    {
        path: '/login',
        name: 'login',
        component: () =>
            import ('../views/login/Login'),
    },
    {
        path: '/register',
        name: 'register',
        component: () =>
            import ('../views/register/Register'),
    },
    {
        path: '/botnav',
        name: 'botnav',
        component: () =>
            import ('../views/botnav/Botnav'),
        redirect: '/botnav/home',
        children: [{
                path: 'home',
                name: 'home',
                component: () =>
                    import ('../views/home/Home')
            }, {
                path: 'collect',
                name: 'collect',
                component: () =>
                    import ('../views/collect/Collect')
            }, {
                path: 'mine',
                name: 'mine',
                component: () =>
                    import ('../views/mine/Mine')
            },
            {
                path: 'order',
                name: 'order',
                component: () =>
                    import ('../views/order/Order')
            }

        ]
    },
    {
        path: '/menu',
        name: 'menu',
        component: () =>
            import ('../views/main/Menu.vue')
    },
    {
        path: '/room',
        name: 'room',
        component: () =>
            import ('../views/main/Room.vue')
    },
    {
        path: '/pay',
        name: 'pay',
        component: () =>
            import ('../views/pay/Pay.vue'),
    },
    {
        path: '/book',
        name: 'book',
        component: () =>
            import ('../views/main/Book.vue'),
    },

    {
        path: '/serve',
        name: 'serve',
        component: () =>
            import ('../views/main/Serve.vue'),
    },
    {
        path: '/particluars',
        name: 'particluars',
        component: () =>
            import ('../views/order/particluars.vue'),
    },
]
const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router